package com.sinocare.report.controller;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.sinocare.common.entity.vo.RecordReport;
import com.sinocare.common.result.Result;
import com.sinocare.common.result.ResultCode;
import com.sinocare.report.service.AcrossService;
import com.sinocare.report.service.RecordReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/RecordReport")
@Api(tags = "报表管理接口")
public class RecordReportController {
    @Resource
    private RecordReportService recordReportService;

    //检测记录报表：查询所有
    @ApiOperation(value = "检测记录报表：查询所有", notes = "检测记录报表：查询所有", httpMethod = "GET")
    @RequestMapping(value = "recordreport", method = RequestMethod.GET)
    public Result findTestRecordReport(Integer page , Integer limit, String searchParams) throws Exception {
        ObjectMapper objectMapper = new ObjectMapper();
        RecordReport recordReport= null;
        if(searchParams != null){
            recordReport= objectMapper.readValue(searchParams, RecordReport.class);
        }
        Page page1 = PageHelper.startPage(page, limit);
        List<RecordReport> list = recordReportService.query(null);
        System.out.println(list);
        return Result.ok(ResultCode.SUCCESS, page1.getTotal(), list);
    }
}
